<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>预览许可证书</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
			.titleCss{
				font-size:200%;
				text-align:center;
				font-weight: bold;
			}
			.titile1Css{
				font-size:350%;
				text-align:center;
				font-weight: bold;
			}
			.justifyCss{
				width:20%;
				text-align:justify;
				text-justify:distribute-all-lines;
				text-align-last:justify;
			}
			.tdCss{
				font-size:130%;
				font-weight: bold;
			}
			.tdcontentCss{
				font-size:180%;
				font-weight: bold;
			}
			.inputNoborder {
			    FONT-SIZE: 25px;
			    FONT-FAMILY: 宋体;
			    BORDER-RIGHT: #FFFFFF 1px solid;
			    BORDER-TOP: #FFFFFF 1px solid;
			    BORDER-LEFT: #FFFFFF 1px solid;
			    BORDER-BOTTOM: #FFFFFF 1px solid;
			}
				.inputNoborder2 {
			    FONT-SIZE: 18px;
			    FONT-FAMILY: 宋体;
			    BORDER-RIGHT: #FFFFFF 1px solid;
			    BORDER-TOP: #FFFFFF 1px solid;
			    BORDER-LEFT: #FFFFFF 1px solid;
			    BORDER-BOTTOM: #FFFFFF 1px solid;
			}
				.inputNoborder1 {
			    FONT-SIZE: 18px;
			    FONT-FAMILY: 宋体;
			    BORDER-RIGHT: #FFFFFF 1px solid;
			    BORDER-TOP: #FFFFFF 1px solid;
			    BORDER-LEFT: #FFFFFF 1px solid;
			    BORDER-BOTTOM: #FFFFFF 1px solid;
			}
		</style>
		
		<script type='text/javascript' src="${ctx}/dwr/engine.js"></script>
		<script type='text/javascript' src="${ctx}/dwr/util.js"></script>
		<script type='text/javascript' src="${ctx}/dwr/interface/FileUploadCntl.js"></script>
		<script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>
		<script src="${ctx}/gzcgwsp/resources/js/YwEnterprise.js" type="text/javascript"></script>
		<script src="${ctx}/resources/js/jquery/jquery.js" type="text/javascript"></script>
		<script src="${ctx}/gzcgwsp/shljcz/js/csshljcz.js" type="text/javascript"></script>
		<script src="${ctx}/gzcgwsp/resources/js/YwUtil.js" type="text/javascript"></script>
		<script src="${ctx}/gzcgwsp/resources/js/validator.js" type="text/javascript"></script>
		<script type="text/javascript">  
	var contextpath="<%=basePath%>";
		var fileSavePath=getPathBySystem(); 
		//根据操作系统用不同的路径
		function getPathBySystem(){
		     var path="";
		     var ua = navigator.userAgent.toLowerCase();
		     if(ua.indexOf("linux")>=0){
		        path="/usr/local/temp";
		     }else{
		        path="C:\\TEMP\\";
		     }
		    return path;
		}
		
		//盖章按钮
        function gzJyxkzs(){
           var chinesename = document.getElementById("sqdw").value+
           					document.getElementById("acceptNo").value+"许可证.xls";
           
           var filepath=contextpath+"/"+document.getElementById("templateFilePath").value;
  		   var filename = filepath.substring(filepath.lastIndexOf("/")+1);
  		   TransUpload(filename,chinesename,filepath)
        }
    
		function TransUpload(result,chinesename,filepath){
			var newpath=MakeWord(result,chinesename,filepath);// 打开word ，把它保存在D盘，相当于下载
			var DocName, CebName, LogName, IniName;
			var DocNameLen;
			var DocNameWONLen;
			var cebtail;
		//	DocName = NewDocForm.OriginalFile.value;
		 	DocName =newpath;
			DocNameLen = DocName.length;
			DocNameWONLen = DocName.lastIndexOf(".") - 1;
			if (DocNameWONLen == -1){
				DocNameWONLen = DocNameLen;
			}else{
				cebtail = DocName.substring(DocNameWONLen+2, DocNameLen);
			}
			if (cebtail.toLowerCase() == "ceb"){
				CebName = DocName;
			}else{
				CebName = DocName.substring(0, DocNameWONLen+1) + ".ceb";
			}
			
			LogName = DocName.substring(0, DocNameWONLen+1) + ".log";
			IniName = DocName.substring(0, DocNameWONLen+1) + ".ini";
			if (DocName != CebName){
				if (!(transMaker(DocName, CebName, LogName, IniName))){// 格式转换
					alert("格式转换失败，请重试！");
					return false;
				}		
			}
			else{
				alert("当前格式为ceb格式！");
			}
			var f=newpath.substring(0,newpath.lastIndexOf("."))+".ceb";
			Stamp_onclick(f);//盖章
			document.getElementById("t1").value=f;
			callSet(chinesename);//上传
			return true;

		}
		//格式转换
		function transMaker(DocName, CebName, LogName, IniName){
			var DTracker;
			DTracker = new ActiveXObject("MakerCom.MakerExt.1");
			var nRet;
			var Error;
			//alert("正转换文件，请稍候......");		
			nRet = DTracker.BeginMaker("");
			if (nRet != 0){
				alert(DTracker.GetErrorMessage(nRet));		
				delete DTracker;
				return false;
			}		
		    //alert("开始文档格式转换......请稍后!");		
			nRet = DTracker.SingleFileConvert(DocName, CebName, "标准模板", LogName, IniName);	
			if (nRet != 0){
				alert("MakerOcx transfer error!");
				nRet = DTracker.EndMaker();		
				delete DTracker;
				return false;
			}
			nRet = DTracker.EndMaker();
			if (nRet != 0){
				alert("MakerOcx End error!");		
				delete DTracker;
				return false;
			}	
			alert("格式转换完成！");	
			delete DTracker;
			return true;
		}
		//文件保存到本地
		 function MakeWord(filename,chinesename,filepath){
	        var WordApp=new ActiveXObject("Excel.Application");
	        var newpath=fileSavePath+chinesename;
	        var url=filepath;
        	WordApp.Visible = false;
	        var Doc=WordApp.Workbooks.open(url);
	        Doc.saveAs(newpath);
	        Doc.Close();
	        WordApp.Application.Quit();
	        return newpath;
 		}
        </script>
        <script language="vbs">
Function Stamp_onclick(strCEBFileName)    	
	Dim strErrMessage, lRet, objStampClientTool,g_AffixRegisterURL,g_SendPrintURL,UnitName
	g_AffixRegisterURL="http://172.16.253.169/StampServer/interfaces/background/AffixRegister.aspx"
	g_SendPrintURL="http://172.16.253.169/StampServer/extend/interfaces/SendPrint.aspx"
	UnitName=""

	lRet = ""
	strErrMessage = ""
	strCEBFileName = trim(strCEBFileName)

	if  0 = len(trim(strCEBFileName)) then
		Call Alert("请选择CEB文件！", vbExclamation, "请选择CEB文件！")
		Exit Function
	else
		if UCase(Right(Trim(strCEBFileName), 3)) <> "CEB" then
			Call Alert("只能选择CEB格式的文件！", vbExclamation, "只能选择CEB格式的文件！")
			CEBFileName.value = ""
			Exit Function
		end if                  	 	  
	end if

	set objStampClientTool  = CreateObject("StampClientTool.StampTool")

	' 本地可视化盖章	
	lRet = objStampClientTool.LocalSealStamp(strCEBFileName, UnitName, g_AffixRegisterURL, g_SendPrintURL)
	
	if lRet <> 0 then
		strErrMessage = objStampClientTool.GetErrorMessage()
        alert "盖章失败原因:" & strErrMessage
	end if

	Set objStampClientTool = Nothing	
End Function

Sub PreviewCEB(xuwei)
	Dim lRet
	lRet = DCreateGBForm1.ViewLocalCEB(xuwei)
End Sub

Sub PreviewNetCEB(xuwei)
	Dim lRet
	lRet = DCreateGBForm1.ViewNetCEB(xuwei)
End Sub

</script>
	</head>
	<body>
		<form action="" method="POST" id="xkzForm">
		<input type="hidden" name="id" value="${id}"/>
		<input type="hidden" id="activityName" value="${hjmc}"/>
		<input type="hidden" id="templateCode" value="${templateCode}"/>
		<input type="hidden" id="sqdw" value="${sqdw}"/>
		<input type="hidden" id="acceptNo" value="${acceptNo}"/>
		<input type="hidden" name="templateFilePath" id="templateFilePath" value="${templateFilePath}">
		<table width="1024" border=0 align="center">
			<tr>
				<td class="titleCss" colspan="3">广&nbsp;州&nbsp;市&nbsp;建&nbsp;筑&nbsp;废&nbsp;弃&nbsp;物&nbsp;处&nbsp;置&nbsp;证（运输）</td>
			</tr>
			<tr>
			<td colspan="3">	&nbsp;&nbsp;</td>
			</tr>
			<tr height="40">
				<td colspan="2" align=""></td>
				<td colspan="" align="center" class="tdCss">NO.&nbsp;&nbsp;<input name="certificateNo" value="${certificateNo}" maxlenth="10" size="10" class="inputNoborder1"/>号</td>
			</tr>
			<tr>
				<td class="tdCss" style="width:18%">企&nbsp;&nbsp;&nbsp;&nbsp;业&nbsp;&nbsp;&nbsp;&nbsp;名&nbsp;&nbsp;&nbsp;&nbsp;称：</td>
				<td class="tdCss" colspan="2" style="width:50%"> <input name="sqdw" readonly value="${sqdw}" class="inputNoborder" style="width:100%;"/></td>
			</tr>
			<tr>
				<td class="tdCss">单&nbsp;&nbsp;&nbsp;&nbsp;位&nbsp;&nbsp;&nbsp;&nbsp;地&nbsp;&nbsp;&nbsp;&nbsp;址：</td>
				<td class="tdCss" colspan="2"><input name="address" value="${address}" readonly class="inputNoborder" style="width:100%;"/></td>
			</tr>
			<tr>
				<td class="tdCss">法定代表人：</td>
				<td class="tdCss" colspan="2"><input name="frxm" readonly value="${frxm}" class="inputNoborder" style="width:100%;"/></td>
			</tr>
			<tr>
				<td class="tdCss">许&nbsp;&nbsp;&nbsp;&nbsp;可&nbsp;&nbsp;&nbsp;&nbsp;范&nbsp;&nbsp;&nbsp;&nbsp;围：</td>
				<td class="tdCss" colspan="2"><input name="xkfw"  value="${xkfw}" class="inputNoborder" style="width:100%;"/></td>
			</tr>
			<tr height="60">
			 <td colspan="3">&nbsp;</td>
			</tr>
			<tr>
				<td class="tdcontentCss" colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;根据《广州市市容环境卫生管理规定》第四十九条规定，经审核，<br>
				你单位符合建筑废弃物运输处置的许可条件，准予发证。
				</td>
			</tr>
			<tr height="30">
			 <td colspan="3">&nbsp;</td>
			</tr>
			<tr>
				<td class="" colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【法律、行政法规禁止的，不得经营；法律、行政法规限制的项目须取得相关放可文件后方可经营】
				
				</td>
			</tr>
			<tr height="30">
			 <td colspan="3">&nbsp;</td>
			</tr>
			<tr>
			<td class="" style="width:10%">有效期限至：</td>
				<td class="" style="width:45%">
				<input name="endYear"  onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${endYear}" maxlength="4" class="inputNoborder2" style="width:40px;"/>
				年
				<input name="endMonth"  onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${endMonth}"  maxlength="2"  class="inputNoborder2" style="width:25px;"/>
				月
				<input name="endDay"   onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${endDay}"  maxlength="2" class="inputNoborder2" style="width:25px;"/>
				日
				</td>
				<td class="" style="width:45%">
				<input name="startYear"  onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${startYear}" maxlength="4" class="inputNoborder2" style="width:40px;"/>
                  年
                <input name="startMonth" onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${startMonth}"  maxlength="2"  class="inputNoborder2" style="width:25px;"/>
                  月
                <input name="startDay"   onKeyUp="javascript:clearNoNum(event,this)" onBlur="javascript:checkNum(this)"  value="${startDay}"  maxlength="2" class="inputNoborder2" style="width:20px;"/>
				日
				</td>
			
			</tr>
		
		
			<tr>
				<td colspan="3" style="text-align:center;">
					<input type="button" onclick="gzJyxkzs();"  id="printzs" value="盖章" style="width:100px;"/>
					<input type="button" onclick="viewJyxkzs();"  id="printzs" value="查看盖章" style="width:100px;"/>
					<input type="button" value="关闭窗口" onclick="window.close();" style="width:100px;"/>
				</td>
			</tr>
		</table>
		</form>
	
	</body>
</html>